import {importStores,importBlocks,importSlots,importDialogs} from 'zbee-webpack'
import {ElTimeline,ElTimelineItem} from 'element-plus';
const {
  useBasicFormStore,
  useBasicTableStore
} = importStores();
import {ElMessage} from 'element-plus';
import {h} from 'vue';//引入渲染函数
function renderTimeline(){
  const timelineItems = [
    { timestamp: '2022-01-01', image: 'https://ts1.cn.mm.bing.net/th/id/R-C.96bb6980beaf8b163df8580eeb55fa25?rik=sVp19xuW4Wv1mw&riu=http%3a%2f%2fimage.yjcf360.com%2fu%2fcms%2fwww%2f202003%2f0409025706kz.jpg&ehk=N1hJL8ComUYm0NThkeqmLSNfDVAJWFElfAzxcK5SpUM%3d&risl=&pid=ImgRaw&r=0'},
    { timestamp: '2022-02-01', image: 'https://ts1.cn.mm.bing.net/th/id/R-C.96bb6980beaf8b163df8580eeb55fa25?rik=sVp19xuW4Wv1mw&riu=http%3a%2f%2fimage.yjcf360.com%2fu%2fcms%2fwww%2f202003%2f0409025706kz.jpg&ehk=N1hJL8ComUYm0NThkeqmLSNfDVAJWFElfAzxcK5SpUM%3d&risl=&pid=ImgRaw&r=0' },
    { timestamp: '2022-03-01', image: 'https://ts1.cn.mm.bing.net/th/id/R-C.96bb6980beaf8b163df8580eeb55fa25?rik=sVp19xuW4Wv1mw&riu=http%3a%2f%2fimage.yjcf360.com%2fu%2fcms%2fwww%2f202003%2f0409025706kz.jpg&ehk=N1hJL8ComUYm0NThkeqmLSNfDVAJWFElfAzxcK5SpUM%3d&risl=&pid=ImgRaw&r=0' },
  ];

  return h(ElTimeline, timelineItems.map(item => {
    return h(ElTimelineItem, { timestamp: item.timestamp,color:'red' }, [
      h('img', { src: item.image, alt: 'Random Image',style:{width:'200px'} }),
      h('p', 'Event description'),
    ]);
  }));
}
import {main} from './index.module.scss'
const{data:modelValue} = useBasicFormStore();
const{data: tabledata} = useBasicTableStore();
console.log('[Store]',tabledata)
function create(nums){
    let template ={
      widget:"verticalLayout",
    items:[
    {
      widget:'text',
      modelValue:'测试代码'
    }]}
    tabledata.map((item)=>{
      template.items.push({
        widget: 'text',
        modelValue: item.category ,
      })
    }) 
    ElMessage({
      message:'fuck you life!',
      type: 'success'
    });
    return template;
    
}
export default {
  body: {
    class:main,
    onMounted:[
      {
        action: 'set',
				target: '$widgets.userInfoForm',
				field: 'modelValue',
				value: modelValue,
      }
    ],
    widget:"verticalLayout",
    items: [
      {
        id: "userInfoForm",
        widget: "form",
        labelWidth: "100px",
        labelPosition: "right",
        fields: [
          {
            widget: "horizontalLayout",
            mode: "flex",
            gutter:10,
            items: [ {
              span:4,
              field: "TotalNumber",
              widget: "datePicker",
              label: "单据日期:",
              placeholder: "2",
              },
              { span:4,
                field: "cost",
                widget: "input",
                label: "单据编号",
                disabled:true,
              },
              { span:4,
                field: "QuotationRatio",
                widget: "input",
                label: "报价类型:",
                disabled:true,
                placeholder: "1 : 1.6",
              }
            ],
          },{
            items:create(10)
          },{
            items:renderTimeline()
          },
          {
            widget:"horizontalLayout",
            mode:'flex',
            gutter:20,
            items:[
              {
                label: "综合成本:",
                span:4,
                field:'TotalPrice',
                disabled:true,
                widget: "input",
              }, {  
                field:'PreferentialPrices',
                span:4,
                label: "费用总计:",
                disabled:true,
                widget: "input",
              }, {  
                field:'QuotationDepartment',
                span:4,
                label: "报价比例：",
                widget: "text",
              },{
                flex:true
              },{
                widget:"horizontalLayout",
                mode:'flex',
                items:[
                  {
                    widget:"verticalLayout",
                    items:[
                      {
                        widget: 'text',
                        field:'TotalPrice',
                        style:{
                         'font-size':'28px',
                         'color':'red'
                        },
                      },{
                        widget: 'text',
                        modelValue: '(报备价格)' ,
                        },{
                          widget: 'text',
                          modelValue:modelValue.TotalPrice
                        }
                     ]
                  },{
                    widget: 'button',
                    text:'提交审核',
                    type:'primary'
                  }
                ]
              }
            ]
          }]
      },]
  },
};
